/**
 入驻小区
 **/
(function (vc) {
    vc.extends({
        data: {
            selectCommunityFloorInfo: {
                floors: [],
                communityId: '',
                callBack:{}
            }
        },
        _initMethod: function () {
            
        },
        _initEvent: function () {
            vc.on('selectCommunityFloor','initCommunityFloor',function(param){
                $that.selectCommunityFloorInfo.callBack = param.callBack;
                $that._loadCommunityFloors();
            })
        },
        methods: {
            _loadCommunityFloors: function () {
                let param = {
                    params: {
                        _uid: '123mlkdinkldldijdhuudjdjkkd',
                        page: 1,
                        row: 100,
                        communityId:vc.getCurrentCommunity().communityId
                    }
                };
                let _floors = [{
                    floorNum: '全部',
                    floorId: ''
                }];
                $that.selectCommunityFloorInfo.floors = _floors;
                vc.http.apiGet('/floor.queryFloors',
                    param,
                    function (json, res) {

                        let _json = JSON.parse(json);
    
                        _json.apiFloorDataVoList.forEach(c => {
                            _floors.push(c);
                        });
                        $that.selectCommunityFloorInfo.floors = _floors;
                        $that._swatchCommunityFloor(_floors[0]);
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            _swatchCommunityFloor: function (_floor) {
                $that.selectCommunityFloorInfo.floorId = _floor.floorId;
                //todo 切换小区
                $that.selectCommunityFloorInfo.callBack(_floor);
            }
        }
    });
})(window.vc);